<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/header.css" />
	</head>

	<body>

		<header class="mui-bar mui-bar-nav title">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white;"></a>
			<a id="link_submit_report" class="mui-icon mui-icon-right-nav mui-pull-right"
				style="color: white;font-size: 14px;line-height: 27px;">提交</a>
			<h1 class="mui-title title-color">实习报告填写</h1>
		</header>

		<div class="mui-content">
			<div class="mui-input-row">
				<label>标题</label>
				<input id="report_title" type="text" placeholder="默认为企业编号,不需填写" readonly="true">
			</div>
			<div class="mui-input-row">
				<textarea rows="23" cols="20" id="report_content" style="height: 100%;"
					placeholder="请填写实习报告"></textarea>
			</div>
			<div class="mui-input-row">
				<label>分数:</label>
				<input id="report_mark" type="text" placeholder="默认为企业编号,不需填写" readonly="true">
			</div>
			<div class="mui-input-row">
				<label>评语:</label>
			</div>
			<div class="mui-input-row">
				<textarea rows="15" cols="20" id="correct_content" style="height: 100%;"
					readonly="true"></textarea>
			</div>
		</div>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/app.js"></script>
		<script type="text/javascript">
			mui.init()

			mui.plusReady(function() {
				var user = app.getGlobalUserInfo();

				// 获取当前页面webview
				var reportEditWebview = plus.webview.currentWebview();
				
				// 获取上一个页面传入的企业编号
				var ir_e_id = reportEditWebview.ir_e_id;
				var ir_content = reportEditWebview.ir_content;
				var ir_mark = reportEditWebview.ir_mark;
				var ir_remark = reportEditWebview.ir_remark;

				var report_title = document.getElementById("report_title");
				report_title.value = ir_e_id;

				var report_content = document.getElementById("report_content");
				report_content.value = ir_content;
				
				var report_mark = document.getElementById("report_mark");
				var correct_content = document.getElementById("correct_content");
				
				if (ir_mark != null && ir_mark != '') {
					report_mark.value = ir_mark;
					correct_content.value = ir_remark;
				} else {
					report_mark.value = "暂无分数";
					correct_content.value = "暂无评语";
				}

				var link_submit_report = document.getElementById("link_submit_report");
				link_submit_report.addEventListener("tap", function() {

					if (report_title.value != null && report_content.value != null) {
						
						mui.ajax(app.serverUrl + "/user/student/insert_student_report?ir_title=" + report_title.value +
							"&ir_content=" + report_content.value +
							"&ir_stu_id=" + user.user_id +
							"&ir_e_id=" + report_title.value, {
								data: {},
								dataType: 'json', //服务器返回json格式数据
								type: 'post', //HTTP请求类型
								timeout: 10000, //超时时间设置为10秒；
								headers: {
									'Content-Type': 'application/json'
								},
								success: function(data) {
									app.showToast("上传实习报告成功！", "success");
									// 打开学生功能列表页面
									mui.openWindow({
										url: "studentContent.html",
										id: "studentContent.html",
										createNew: true
									});
								}
							});
					} else {
						app.showToast("标题和内容不允许为空！", "error");
					}

				})
			});
		</script>
	</body>

</html>
